package com.wesley.compose;

import javax.management.ObjectName;
import java.util.ArrayList;
import java.util.List;

/**
 * <h1>Composite角色</h1>
 * <p>大学</p>
 *
 * @Date: 2021/8/19
 */
public class University implements OrgComponent {

    private final List<OrgComponent> components;

    private String name;

    public University(String name) {
        components = new ArrayList<>();
        this.name = name;
    }

    @Override
    public void add(OrgComponent orgComponent) {
        components.add(orgComponent);
    }

    @Override
    public void remove(OrgComponent orgComponent) {
        components.remove(orgComponent);
    }

    @Override
    public void print() {
        System.out.println("↓↓↓↓↓↓↓↓↓ " + name + "大学 ↓↓↓↓↓↓↓↓");
        System.out.println("--------------------");
        components.forEach(OrgComponent::print);
    }
}
